package com.tmt.im.common.pojo;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.tmt.im.common.annotation._AllowUpdate;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.SuperBuilder;
import org.apache.ignite.cache.query.annotations.QuerySqlField;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serial;
import java.io.Serializable;
import java.sql.Timestamp;

/**
 * 聊天会话成员PoJo对象
 *
 * @Description TODO
 * @Author wuyi
 * @Date 2024/8/7 15:07
 * @Version 1.0
 **/
@Getter
@Setter
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
public class ChatSessionMemberPoJo implements IGetKey<SessionMemberKey>, Serializable {

    @Serial
    private static final long serialVersionUID = -5599356466969798541L;

    public static final String CACHE_NAME = "chat_session_member";

    @QuerySqlField(name = "id", index = true)
    private Long id;

    @QuerySqlField(name = "id", index = true)
    @JsonIgnore
    private Long mid;

    /**
     * 是否禁止成员在该群中抢手气红包。
     */
    @_AllowUpdate
    @QuerySqlField(name = "forbid_red_package")
    private boolean forbidRedPackage = false;

    /**
     * 是否禁止成员在该群中发言。
     */
    @_AllowUpdate
    @QuerySqlField(name = "chat_banned")
    private boolean chatBanned = false;

    /**
     * 是否开启免打扰;
     */
    @_AllowUpdate
    @QuerySqlField(name = "do_not_disturb")
    private boolean doNotDisturb = false;

    /**
     * 本群是否被用户设置为了"置顶"
     */
    @_AllowUpdate
    @QuerySqlField(name = "hold_in_top")
    private boolean holdInTop = false;

    /**
     * 在群中的角色： 1——群主，2——管理员，3——普通成员。
     */
    @QuerySqlField(name = "role_in_session")
    @_AllowUpdate
    private int roleInSession;

    /**
     * 最后一条发送给memberId成员的数据的ID, 0表示未发送过数据
     * 本属性是为本地消息推送的而设计的，因采用了云信平台，本属性已废弃。
     */
    @_AllowUpdate
    @QuerySqlField(name = "last_data_id")
    @JsonIgnore
    private Long lastDataId = 0L;

    /**
     * 成员ID
     */
    @QuerySqlField(name = "member_id")
    private Long memberId;

    /**
     * 成员群昵称
     */
    @QuerySqlField(name = "member_nick")
    @_AllowUpdate
    private String memberNick;

    /**
     * 聊天会话ID
     */
    @QuerySqlField(name = "session_id")
    private Long sessionId;

    /**
     * 邀请信息。
     */
    @QuerySqlField(name = "invite_msg")
    private String inviteMsg;

    /**
     * 群主或管理员对邀请入群或申请入群的审核结果。
     */
    @QuerySqlField(name = "check_status")
    @_AllowUpdate
    @JsonIgnore
    private int checkStatus = 0;

    /**
     * 审核的群主或管理员的ID。
     */
    @QuerySqlField(name = "checker_id")
    @_AllowUpdate
    @JsonIgnore
    private Long checkerId;

    /**
     * 群主或管理员对邀请入群或申请入群的审核时间。
     */
    @QuerySqlField(name = "check_time")
    @_AllowUpdate
    @JsonIgnore
    private Timestamp checkTime;

    /**
     * 被邀请人同意或拒绝入群。
     */
    @QuerySqlField(name = "agree_status")
    @_AllowUpdate
    @JsonIgnore
    private int agreeStatus = 0;

    /**
     * 被邀请人同意或拒绝入群的时间。
     */
    @QuerySqlField(name = "agree_time")
    @_AllowUpdate
    @JsonIgnore
    private Timestamp agreeTime;

    @QuerySqlField(name = "deleted")
    @_AllowUpdate
    private boolean deleted = false;

    @QuerySqlField(name = "delete_time")
    @_AllowUpdate
    private Timestamp deleteTime;

    /**
     * 数据版本
     */
    @QuerySqlField(name = "version")
    private Long version;

    /**
     * 创建者ID。
     */
    @QuerySqlField(name = "creator_id")
    @JsonIgnore
    private Long creatorId;

    /**
     * 创建时间
     */
    @QuerySqlField(name = "create_time", index = true)
    private Timestamp createTime;

    @JsonIgnore
    private boolean insert = true;

    @Override
    public SessionMemberKey getKey() {
        return new SessionMemberKey(id, sessionId);
    }

}
